package com.hema.auction.adapter;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.hema.auction.R;
import com.hema.auction.bean.GoodTypeInfo;

import java.util.List;

/**
 * author by john
 */

public class GoodsTabAdapter extends BaseQuickAdapter<GoodTypeInfo, BaseViewHolder> {
    private int selectedItem;
    public GoodsTabAdapter(@Nullable List<GoodTypeInfo> data) {
        super(R.layout.layout_goods_tab_item, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, GoodTypeInfo item) {
        helper.setText(R.id.tv_name,item.getName());
        if(selectedItem == helper.getLayoutPosition()){
            helper.setBackgroundColor(R.id.tv_name,mContext.getResources().getColor(R.color.white));
        }else{
            helper.setBackgroundColor(R.id.tv_name,mContext.getResources().getColor(R.color.layout_bg));
        }
    }

    public void selected(int position){
        selectedItem = position;
    }
}
